#ifndef SOLUTION_H_
#define SOLUTION_H_
#ifndef NULL
#define NULL 0
#endif
struct ListNode
{

	int val;
	ListNode *next;
	ListNode(int x) : val(x), next(NULL) {}
};

class Solution
{

public:
	ListNode *deleteDuplicates(ListNode *head)
	{
		// Start typing your C/C++ solution below
		// DO NOT write int main() function
		if(!head)
			return NULL;

		ListNode *last = head, *current = head->next;
		while(current)
		{
			if(current->val != last->val)
			{
				last = last->next;
				last->val = current->val;
			}
			current = current->next;
		}

		last->next = NULL;
		return head;
	}
};
#endif